home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2000 July / macformat-092.iso / Fireworks 3 / Settings / HTML Code / CssLayers.htt next >
Encoding:
Text File  |  1999-11-19  |  4.4 KB  |  141 lines

  1. // Fireworks Css Layer output.
  2. // Version 2.0 25JAN99
  3.  
  4.  
  5. // Write general comments for copying and pasting Fireworks-generated code into existing HTML documents.
  6. WRITE_HTML("<!-- To put this html into an existing HTML document, you must copy and \n");
  7. WRITE_HTML("paste code from within the body tag of this document into the body tag \n");
  8. WRITE_HTML("of the target document. -->\n");
  9. WRITE_HTML("\n")
  10.  
  11.  
  12. WRITE_HTML("<html>\n");
  13. WRITE_HTML("\n")
  14.  
  15. WRITE_HTML("<head>\n");
  16. WRITE_HTML("\n")
  17.  
  18. // Use Base Name from export dialog as document title.
  19. WRITE_HTML("<title>", exportDoc.filename, "</title>\n");
  20. WRITE_HTML("\n")
  21.  
  22. // Write Meta tags.
  23. WRITE_HTML("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n"); 
  24. WRITE_HTML("<meta name=\"description\" content=\"Fireworks CSS Layer\">\n");
  25. WRITE_HTML("\n")
  26.  
  27. // Write HTML target and date created.
  28. var d = new Date();
  29. WRITE_HTML("<!-- Fireworks 2.0  Css Layers.  \n    Created ", d, " -->\n");
  30. WRITE_HTML("\n")
  31.  
  32. // Close head tag.
  33. WRITE_HTML("</head>\n");
  34. WRITE_HTML("\n")
  35.  
  36. // Function LayerName determines the name of the current layer.
  37. function LayerName(str) {
  38.     var newName = str.toString().replace(/_/g, "");
  39.     newName = newName.replace(/ /g, "");
  40.     if (newName == "") newName = "EmptyName";
  41.     if (!newName) newName = "EmptyName";
  42.     if (newName.search(/\d/) == 0) {
  43.         newName = "L"+newName;
  44.     }
  45.     return(newName);
  46. }
  47.  
  48. // Function CellName determines the name for the image in a particular table cell.
  49. // Cellname is based off of the slice name if one was specified. Otherwise the
  50. // Base file name from the export dialog is used.
  51. function CellName(str, row, col) {
  52.     var cellName = str.toString();
  53.     // remove illegal characters
  54.     cellName = cellName.replace(/\W/g, "");
  55.     // if it starts with a number, add N to the front.
  56.     if (cellName == "") {
  57.         cellName = "N" + exportDoc.imagename + "_" + (row+1) + "_" + (col+1);
  58.         // remove illegal characters
  59.         cellName = cellName.replace(/\W/g, "");
  60.     }
  61.     if (cellName.search(/\d/) == 0) {
  62.         cellName = "N"+cellName;
  63.     }
  64.     return(cellName);
  65. }
  66.  
  67. // Begin body tag. Set background color to Fireworks document canvas color.
  68. WRITE_HTML("<body bgcolor=\"#", exportDoc.backgroundColor, "\">\n");
  69. WRITE_HTML("\n")
  70.  
  71. // Write comment for start of code copy/paste section.
  72. WRITE_HTML("<! ------------------------ BEGIN COPYING THE CODE HERE -------------------------->\n");
  73. WRITE_HTML("\n");
  74.  
  75. // Analyze each slice and determine whether or not an image file is exported.
  76.     var curCol;
  77.     var curRow;
  78.     var curSlice;
  79.     var curZ = 1;
  80.     for (curRow = 0; curRow < slices.numRows; curRow++) {
  81.         for (curCol = 0; curCol < slices.numColumns; curCol++) {
  82.             curSlice = slices[curRow][curCol];
  83.             
  84.             if (curSlice.skipCell) continue; 
  85.  
  86.             if (!curSlice.hasImage) {
  87.                 // no image
  88.                 continue;
  89.             }
  90.  
  91.             if (curSlice.isUndefined && slices.doSkipUndefined) {
  92.                 curSlice.setFrameFileName(0, "");
  93.                 continue;
  94.             }
  95.             if (curSlice.isUndefined) {
  96.                 curSlice.setFrameFileName(0, "");
  97.                 continue;
  98.             }
  99.  
  100.             if (curSlice.hasImage) {
  101.  
  102.                 // Determine the current slice's file name and name the layer accordingly.
  103.                 var imageName = curSlice.getFrameFileName(0);
  104.                 if (imageName == "") continue;
  105.                 var layerName = LayerName(imageName);
  106.                 var cellName = CellName(imageName, curRow, curCol);
  107.                 
  108.                 // Write the div tag to specify layer. Obtain and enter height, width and 
  109.                 // positioning information.
  110.                 // Ex: <div id="Layer1" style="position:absolute; left:35px; top:34px; width:115px; height:96px; z-index:1">
  111.                 WRITE_HTML("<div id=\"", layerName, "\" style=\"position:absolute; ");
  112.                 WRITE_HTML("left:", curSlice.left, "px; top:", curSlice.top, "px;")
  113.                 WRITE_HTML("width:", curSlice.width, "px; height:", curSlice.height, "px;");
  114.                 WRITE_HTML("z-index:", curZ, "; visibility:visible\">");
  115.                 
  116.                 // Place image.
  117.                 // Ex: <img name="N_03_02" src="File_03_02.gif" width="79" height="71" border="0"
  118.                 WRITE_HTML("<img name=\"", cellName, "\" src=\"",
  119.                     slices.imagesDirPath, imageName, curSlice.imageSuffix, "\" width=\"",
  120.                     curSlice.width,"\" height=\"", curSlice.height, "\" border=\"0\"");
  121.                 
  122.                 // Close layer div tag.
  123.                 WRITE_HTML("></div>\n");
  124.                 curZ++;
  125.             }
  126.  
  127.         }
  128.     }        
  129.  
  130. WRITE_HTML("\n");
  131. // Write comment for end of code copy/paste section.
  132. WRITE_HTML("<! ------------------------ STOP COPYING THE CODE HERE -------------------------->\n");
  133. WRITE_HTML("\n");
  134.  
  135. WRITE_HTML("</body>\n")
  136. WRITE_HTML("\n")
  137.  
  138. WRITE_HTML("</html>\n")
  139. WRITE_HTML("\n")
  140.  
  141.